- name: remove some old copr repos for things now in the infra repo.
  file: dest="/etc/yum.repos.d/{{item}}" state=absent
  with_items:
    - patternfly-patternfly1-epel-7.repo
    - ralph-pdc-deps-epel-7.repo
    - sochotni-pdc-test-epel-7.repo
  tags: pdc

- name: install needed packages
  dnf: pkg={{ item }} state=present
  with_items:
  - patternfly1
  - python-pdc
  - xmlsec1
  - mod_auth_mellon
  tags: pdc

- name: Copy over settings_local.py
  template: src=settings_local.py
            dest=/usr/lib/python2.7/site-packages/pdc/settings_local.py
            mode=0600 owner=apache group=apache
  notify: reload httpd
  tags: pdc

- name: Copy over httpd config
  template: src=pdc.conf dest=/etc/httpd/conf.d/pdc.conf
  notify: reload httpd
  tags: pdc

- name: ensure selinux lets httpd do the stuff we need.
  seboolean: name={{ item }} persistent=yes state=yes
  with_items:
  - httpd_can_network_connect_db
  - httpd_can_sendmail
  # XXX - Someday for fedmsg
  #- httpd_can_network_connect
  tags:
  - pdc
  - selinux

- name: create /etc/httpd/saml2
  file: state=directory
        path=/etc/httpd/saml2
        owner=apache group=apache mode=0775
  tags: pdc

- name: Install saml2 idp file (which describes our ipsilon instances).
  copy: src="{{ private }}/files/saml2/idp-{{env}}.xml"
        dest="/etc/httpd/saml2/idp-metadata.xml"
        owner="apache" group="apache" mode=0600
  notify: reload httpd
  tags: pdc

- name: Install domain-specific saml2 certs and metadata
  copy: src="{{ private }}/files/saml2/{{ pdc_domain }}/{{ item }}"
        dest="/etc/httpd/saml2/{{ item }}"
        owner="apache" group="apache" mode=0600
  with_items:
    - certificate.pem
    - certificate.key
    - metadata.xml
  notify: reload httpd
  tags: pdc
